import { Injectable } from '@nestjs/common'
import { CreateAichatDto } from './dto/create-aichat.dto'
import { UpdateAichatDto } from './dto/update-aichat.dto'
import OpenAI from 'openai'

const openai = new OpenAI({
  baseURL: 'https://api.deepseek.com',
  apiKey: ''
})

@Injectable()
export class AichatService {
  // 前端发来的对话内容
  async chatContent(body) {
    const completion = await openai.chat.completions.create({
      messages: [{ role: 'system', content: body.content }],
      model: 'deepseek-chat'
    })

    return completion.choices[0].message.content
  }

  findAll() {
    return `This action returns all aichat`
  }

  findOne(id: number) {
    return `This action returns a #${id} aichat`
  }

  update(id: number, updateAichatDto: UpdateAichatDto) {
    return `This action updates a #${id} aichat`
  }

  remove(id: number) {
    return `This action removes a #${id} aichat`
  }
}
